<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>路由嵌套</title>
</head>
<body>
<div id="app">
    <router-link to="/home">主页</router-link>
    <router-link to="/music">音乐</router-link>
    <router-view></router-view>
</div>
<script src="../instances/vue.js"></script>
<script src="../instances/vue-router.js"></script>
<script>
    let Home = {
        template: `<div>主页</div>`
    }
    let Music = {
        template: `<div>音乐
                        <router-link to="/music/pop">流行</router-link>
                        <router-link to="/music/classic">古典</router-link>
                        <router-view></router-view>
                   </div>`
    }
    let Children = {
        template: `<div>音乐子集{{$route.params.id}}</div>`
    }
    let router = new VueRouter({
        routes: [{
            path: '/',
            redirect: '/home'
        },{
            path: '/home',
            component: Home
        },{
            path: '/music',
            component: Music,
            children: [
                {
                    path: '/music/:id',
                    component: Children
                }
            ]
        }]
    })
    let vm = new Vue({
        el: "#app",
        router
    })
</script>
</body>
</html>